package leetcode;

/**
 * @Classname IsSameTree
 * @Author happytaohaha
 * @Date 2020/3/10
 * @Description 相同的树
 */
public class IsSameTree_0100 {

    public static boolean isSameTree(TreeNode p, TreeNode q) {
        if(p==null && q == null) {return true;}
        if(p==null || q == null) {return false;}
        if (p.val != q.val) {return false;}
        return isSameTree(p.left,q.left) && isSameTree(p.right,q.right);
    }

    public static void main(String[] args) {
        TreeNode a = new TreeNode(1);
        TreeNode b = new TreeNode(-3);
        a.left = b;
        TreeNode a2 = new TreeNode(1);
        TreeNode b2 = new TreeNode(3);
        a2.left = b2;
        System.out.println(isSameTree(a,a2));
    }
}
